package org.lsy;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author SHIYUAN
 */
public class Basic {

    public static String occurOnce(int[] array) {
        Set<Integer> set = new HashSet<>();
        if (array == null || array.length <= 1) {
            return "YES";
        }
        for (int i : array) {
            boolean exits = set.add(i);
            if (!exits) {
                return "NO";
            }
        }
        return "YES";
    }

    public static void main(String[] args) {
	    int[] array1 = new int[]{1,2,3};
	    int[] array2 = new int[]{1,2,1};
        System.out.println(Arrays.stream(array1).mapToObj(String::valueOf).collect(Collectors.joining(",")));
        System.out.println(occurOnce(array1));
        System.out.println(Arrays.stream(array2).mapToObj(String::valueOf).collect(Collectors.joining(",")));
        System.out.println(occurOnce(array2));
    }
}
